/** @file         lzmperf.c
 *  @brief        简要说明
 *  @details      详细说明
 *  @author       lzm
 *  @date         2024-08-05 21:49:46
 *  @version      v1.0
 *  @copyright    Copyright By lizhuming, All Rights Reserved
 *  @blog         https://www.cnblogs.com/lizhuming/
 **********************************************************
 *  @LOG 修改日志:
 **********************************************************
*/
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include <errno.h>
#include <pthread.h>

#include "lwip/opt.h"

#include "lwip/sockets.h"
#include "lwip/sys.h"

#include "lzm_logal_api.h"

#include "lwip/apps/lwiperf.h"

#define lzm_apps_log(...)  LZM_LOG(LZM_LOG_LVL_DEBUG, ##__VA_ARGS__)

static void
lwiperf_report(void *arg, enum lwiperf_report_type report_type,
  const ip_addr_t* local_addr, u16_t local_port, const ip_addr_t* remote_addr, u16_t remote_port,
  u32_t bytes_transferred, u32_t ms_duration, u32_t bandwidth_kbitpsec)
{
  LWIP_UNUSED_ARG(arg);
  LWIP_UNUSED_ARG(local_addr);
  LWIP_UNUSED_ARG(local_port);

  lzm_apps_log(("IPERF report: type=%d, remote: %s:%d, total bytes: %"U32_F", duration in ms: %"U32_F", kbits/s: %"U32_F"\n",
    (int)report_type, ipaddr_ntoa(remote_addr), (int)remote_port, bytes_transferred, ms_duration, bandwidth_kbitpsec));
}


void lzmperf_init(void)
{
    lzm_apps_log("lzmperf_init");
    // lwiperf_start_tcp_server_default(lwiperf_report, NULL);
    lwiperf_start_tcp_server(IP_ADDR_ANY, 12345, lwiperf_report, NULL);
}